
import time,os,sys

# 入口函数
def run():
    print('0.退出')
    print('1.创建活动')
    print('2.创建证书')
    print('3.创建项目')
    print('4.创建Java')
    print('5.创建js')
    print('6.创建php')
    print('7.创建下载')
    print('8.创建其他')
    print('9.创建封面人物')
    print('10.创建语言类')
    cmd = input("请输入指令:")
    if cmd == '0':
        quit()
    elif cmd == '1':
        CreateAct()
    elif cmd == '2':
        CreatCart()
    elif cmd == '3':
        CreatePro()
    elif cmd == '4':
            name = input("请输入文章名称:")
            id = int(time.time())
            filename = name + '_'+str(id)
            WriteFile('../code/java/'+filename+'.md','<!-- '+filename+' -->')
            WriteFile('../code/java/_sidebar.md','* ['+name+'](/code/java/'+filename+'.md)\n')
    elif cmd == '5':
            name = input("请输入文章名称:")
            id = int(time.time())
            filename = name + '_'+str(id)
            WriteFile('../code/js/'+filename+'.md','<!-- '+filename+' -->')
            WriteFile('../code/js/_sidebar.md','* ['+name+'](/code/js/'+filename+'.md)\n')
    elif cmd == '6':
            name = input("请输入文章名称:")
            id = int(time.time())
            filename = name + '_'+str(id)
            WriteFile('../code/php/'+filename+'.md','<!-- '+filename+' -->')
            WriteFile('../code/php/_sidebar.md','* ['+name+'](/code/php/'+filename+'.md)\n')
            
            
    elif cmd == '7':
            code = input("输入创建类型，1为有介绍的，2为没有介绍的")
            name = input("请输入下载名称:")
            if code=='1':
                            id = int(time.time())
                            filename = name + '_'+str(id)
                            WriteFile('../download/'+filename+'.md','<!-- '+filename+' -->')
                            WriteFile('../download/home.md','> * ['+name+'](/download/'+filename+'.md)\n')
            else:
                url = input("请输入下载链接:")
                WriteFile('../download/home.md','> * ['+name+']('+url+')\n')
            

            
    elif cmd == '8':
            name = input("请输入文章名称:")
            id = int(time.time())
            filename = name + '_'+str(id)
            WriteFile('../other/'+filename+'.md','<!-- '+filename+' -->')
            WriteFile('../other/_sidebar.md','* ['+name+'](/other/'+filename+'.md)\n')
            
    elif cmd == '9':
            name = input("请输入封面人物姓名:")
            id = int(time.time())
            filename = name + '_'+str(id)
            WriteFile('../people/'+filename+'.md','<!-- '+filename+' -->')
            WriteFile('../people/_sidebar.md','* ['+name+'](/people/'+filename+'.md)\n') 
    elif cmd == '10':
            lau = input("请输入语言:")
            name = input("请输入文章名字:")
            id = int(time.time())
            filename = name + '_'+str(id)
            WriteFile('../code/'+lau+'/'+filename+'.md','<!-- '+filename+' -->')
            WriteFile('../code/'+lau+'/_sidebar.md','* ['+name+'](/code/'+lau+'/'+filename+'.md)\n') 
    else:
        print('错误')
        
def CreateAct():
    name = input("请输入活动名称:")
    id = int(time.time())
    filename = name + '_'+str(id)
    WriteFile('../aboutme/activity/'+filename+'.md','<!-- '+filename+' -->')
    WriteFile('../aboutme/activity/_sidebar.md','* ['+name+'](/aboutme/activity/'+filename+'.md)\n')
    
def CreatCart():
    name = input("请输入证书名称:")
    id = int(time.time())
    filename = name + '_'+str(id)
    WriteFile('../aboutme/cart/'+filename+'.md','<!-- '+filename+' -->')
    WriteFile('../aboutme/cart/_sidebar.md','* ['+name+'](/aboutme/cart/'+filename+'.md)\n')
    
    
def CreatePro():
    name = input("请输入项目名称:")
    id = int(time.time())
    filename = name + '_'+str(id)
    WriteFile('../aboutme/project/'+filename+'.md','<!-- '+filename+' -->')
    WriteFile('../aboutme/project/_sidebar.md','* ['+name+'](/aboutme/project/'+filename+'.md)\n')
    
def WriteFile(name,content):
    f = open(name,'a',encoding='utf8')
    f.write(content)
    f.close()



if __name__ != '_main_':
    while True:
        run()